package com.daiqee.controller;

import java.io.UnsupportedEncodingException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.daiqee.controller.support.CommonsController;
import com.daiqee.enums.RequestType;
import com.daiqee.pojo.SupplierRepayment;
import com.daiqee.service.impl.SupplierRepaymentService;

/**
 * 供应商还款
 * 
 * <br/>
 * @since JDK 1.8
 * @version  V2.1
 * @author RichardTang 
 * @date: 2018年5月7日 下午5:57:26
 * @package com.daiqee.handler
 * @copyright:Copyright (c) 2018, 1245811923@qq.com All Rights Reserved.
 */
@Controller
@RequestMapping("financial/supplier-repayment")
public class SupplierRepaymentController extends CommonsController<SupplierRepayment>{
	
	@Autowired
	private SupplierRepaymentService  supplierRepaymentService;
	
	@Override
	public boolean warpperAddMethod(SupplierRepayment supplierRepayment) throws Exception {
		supplierRepayment.setSupRepaySum(supplierRepayment.getSumValue());
		isNormalFinish = supplierRepaymentService.insert(supplierRepayment);
		return isNormalFinish;
	}
	
	/**
	 * 查询数据库还款表中是否存在该供应商
	 * 
	 * @param supplierName 
	 * 				供应商名称
	 * 
	 * @return restful风格 Http状态码 Void
	 * @throws UnsupportedEncodingException 
	 */
	@RequestMapping(value="/exist",method=RequestMethod.GET)
	public Object queryIsSupplier(String supplierName) throws UnsupportedEncodingException{
		String param = new String(supplierName.getBytes("ISO8859-1"), "UTF-8");
		isNormalFinish = supplierRepaymentService.querySupplierIsExist(param);
		return restfulResponse.response(isNormalFinish,RequestType.GET);
	}
}
